package net.sourceforge.peers.sdp;

import net.sourceforge.peers.media.MediaManager;

/**
 * 编解码器类型 音频 or 视频 ？
 * @author Mr.Yan
 */
public class Codec {

    //有效负载类型
    private int payloadType;
    private String name;

    public int getPayloadType() {
        return payloadType;
    }

    public void setPayloadType(int payloadType) {
        this.payloadType = payloadType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof Codec)) {
            return false;
        }
        Codec codec = (Codec)obj;
        if (codec.getName() == null) {
            return name == null;
        }
        return codec.getName().equalsIgnoreCase(name);
    }

    @Override
    public String toString() {
        return String.valueOf(RFC4566.TYPE_ATTRIBUTE) + RFC4566.SEPARATOR +
                RFC4566.ATTR_RTPMAP + RFC4566.ATTR_SEPARATOR +
                payloadType + " " + name + "/" +
                MediaManager.DEFAULT_CLOCK + "\r\n";

    }

}
